#!/bin/sh

if [ -n "$_VL_IMPORT_ENV" ] ; then
	return 0;
fi
_VL_IMPORT_ENV=0



# 判断是否为 vl-style 项目
#
# 返回值 : 如果是 vl-style 项目返回 0
function isVLStyleProject() {
	if [ $VL_IS_PROJECT -eq 1 ] ; then
		return 1
	fi
	return 0
}

if checkVariable "$VL_LOCATION" ; then
	if ! checkDir "$VL_LOCATION" ; then
		return 1
	fi
	# 进入到项目目录
	cd "$VL_LOCATION"
fi

VL_DIR_ROOT=`pwd`
VL_DIR_SRC="$VL_DIR_ROOT/src"
VL_DIR_BUILD="$VL_DIR_ROOT/.vl-build"
VL_DIR_DEP="$VL_DIR_BUILD/vl-third"
VL_DIR_DEP_GEN="$VL_DIR_DEP/build"
VL_DIR_DEP_TEMP="$VL_DIR_DEP/.temp"

VL_FILE_CONFIG="$VL_DIR_ROOT/vl_config.sh"
VL_FILE_DEP="$VL_DIR_ROOT/vl_dep"
VL_FILE_CONFIG_AC="$VL_DIR_ROOT/configure.ac"
VL_FILE_COMPILE_OPTIONS="$VL_DIR_ROOT/vl_compile_options.sh"

VL_CACHE_FILE_CONFIG_TS="$VL_DIR_BUILD/vl_config_ts"
VL_CACHE_FILE_DEP_TS="$VL_DIR_BUILD/vl_dep_ts"
VL_CACHE_FILE_CONFIG_AC_TS="$VL_DIR_BUILD/vl_configure_ac_ts"
VL_CACHE_FILE_DEP_OPTIONS="$VL_DIR_BUILD/vl_dep_compile_options"
VL_CACHE_FILE_DEP_COMPILE_LIST="$VL_DIR_BUILD/vl_dep_compile_list"
VL_CACHE_FILE_COMPILE="$VL_DIR_BUILD/vl_compile_cache"

if ! checkFile "$VL_FILE_CONFIG" ; then
	VL_IS_PROJECT=1
	return 0
fi

if ! readProps "$VL_FILE_CONFIG" "VL_NAME" "VL_TYPE" "VL_TOOLCHAIN" "VL_DEP" ; then
		printError "source \"$VL_FILE_CONFIG\" file failed."
		return 1
fi

if ! checkVariable "$VL_NAME" ; then
	printError "VL_NAME not exist"
	return 1
fi

if ! checkVariable "$VL_TYPE" ; then
	printError "VL_TYPE not exist"
	return 1
fi

VL_IS_PROJECT=2